package edu.biwu.sms;

import edu.biwu.constant.EnrollmentStatus;

import java.time.LocalDate;
import java.util.Objects;

public class Student {
    /*学号*/
    private Integer studentid;
    /*姓名*/
    private String name;
    /*语文成绩*/
    private Integer chineseScore;//可以表示null
    /*数学成绩*/
    private Integer mathScore;

    //入学日期
    private LocalDate enrollmentDate;

    /*学生的邮箱*/
    private String emall;

    /*学生的头像*/
    private String avatar;

    /*学生的学籍状态*/
    private EnrollmentStatus enrollmentStatus;


    public Student(Integer studentid, String name, Integer chineseScore, Integer mathScore, LocalDate enrollmentDate, String emall, EnrollmentStatus enrollmentStatus) {
        this(studentid,name,chineseScore,mathScore,enrollmentDate,emall);
        this.enrollmentStatus = enrollmentStatus;
    }

    public Student(Integer studentid, String name, Integer chineseScore, Integer mathScore, LocalDate enrollmentDate, String emall) {
        this(studentid,name,chineseScore,mathScore,enrollmentDate);
        this.emall = emall;
    }

    public String getEmall() {
        return emall;
    }

    public void setEmall(String emall) {
        this.emall = emall;
    }

    public Student(Integer studentid, String name, Integer chineseScore, Integer mathScore, LocalDate enrollmentDate) {
        this.studentid = studentid;
        this.name = name;
        this.chineseScore = chineseScore;
        this.mathScore = mathScore;
        this.enrollmentDate = enrollmentDate;
    }

    public Student(Integer studentid, String name, Integer chineseScore, Integer mathScore) {
        this(studentid,name,chineseScore,mathScore,LocalDate.now());//入学日期默认为当前年月日
    }

    public EnrollmentStatus getEnrollmentStatus() {
        return enrollmentStatus;
    }

    public void setEnrollmentStatus(EnrollmentStatus enrollmentStatus) {
        this.enrollmentStatus = enrollmentStatus;
    }

    public Integer getStudentid() {
        return studentid;
    }

    public void setStudentid(Integer studentid) {
        this.studentid = studentid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getAvatar() {
        return avatar;
    }

    public Integer getChineseScore() {
        return chineseScore;
    }

    public void setChineseScore(Integer chineseScore) {
        this.chineseScore = chineseScore;
    }

    public Integer getMathScore() {
        return mathScore;
    }

    public void setNathScore(Integer nathScore) {
        this.mathScore = nathScore;
    }


    /*求学生的总成绩*/
    public Integer getTotalScore() {
        return chineseScore+mathScore;
    }
    /*展示学生的信息使用该方法*/
    public String toString(){
        return studentid+" "+name+" "+chineseScore+" "+mathScore+" "+emall+
                " "+enrollmentDate+" "+getTotalScore()+" "+avatar+" "+enrollmentStatus;
    }

    public void setMathScore(Integer mathScore) {
        this.mathScore = mathScore;
    }

    public LocalDate getEnrollmentDate() {
        return enrollmentDate;
    }

    public void setEnrollmentDate(LocalDate enrollmentDate) {
        this.enrollmentDate = enrollmentDate;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(name, student.name);
    }

}
